package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Ksqkbdb;
import vip.xiaonuo.smzq.modular.kcl.service.IKsqkbdbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 矿山变动表
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "矿山变动表")
@RestController
@RequestMapping("/kcl/ksqkbdb")
@Validated
public class KsqkbdbController {

    @Resource
    private IKsqkbdbService iKsqkbdbService;

    /**
     * 添加矿山变动表
     */
    @ApiOperation("添加矿山变动表")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Ksqkbdb ksqkbdb) {
        iKsqkbdbService.save(ksqkbdb);
        return CommonResult.ok();
    }

    /**
     * 删除矿山变动表
     */
    @ApiOperation("删除矿山变动表")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iKsqkbdbService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑矿山变动表
     */
    @ApiOperation("编辑矿山变动表")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Ksqkbdb ksqkbdb) {
        iKsqkbdbService.updateById(ksqkbdb);
        return CommonResult.ok();
    }

    /**
     * 矿山变动表分页查询
     */
    @ApiOperation("矿山变动表分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Ksqkbdb>> page() {
        return CommonResult.data(iKsqkbdbService.page(new Ksqkbdb()));
    }
}
